package com.webapp.common;


import com.baomidou.mybatisplus.core.toolkit.StringUtils;

public class AppException extends RuntimeException {

    private static final long serialVersionUID = -3654000148888771364L;

    private ErrorCode code;

    public AppException(ErrorCode code) {
        this.code = code;
    }

    public AppException(ErrorCode code, String message) {
        super(message);
        this.code = code;
    }

    public ErrorCode getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        if (StringUtils.isBlank(super.getMessage())) {
            return code.toString();
        }
        return super.getMessage();
    }
}
